#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int maxSum(vector<int>& nums) {
        unordered_map<int, bool> hash;
        int res = 0, mmax = INT_MIN;
        for (auto& e : nums)
        {
            mmax = max(e, mmax);
            if (e > 0 && hash.find(e) == hash.end())
            {
                res += e;
                hash[e] = true;
            }
        }
        return hash.empty() ? mmax : res;
    }
};